package com.hc.pokemen.feature_pokemen.di

import com.hc.pokemen.core.utils.Constants
import com.hc.pokemen.feature_pokemen.domain.repository.PokemonRepository
import com.hc.pokemen.feature_pokemen.data.remote.PokemonApi
import com.hc.pokemen.feature_pokemen.data.repository.PokemonRepositoryImpl
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
object PokemonModule {


    @Singleton
    @Provides
    fun providerRetrofit(): Retrofit = Retrofit.Builder()
        .baseUrl(Constants.BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .build()

    @Singleton
    @Provides
    fun providerPokemonApi(retrofit: Retrofit): PokemonApi = retrofit.create(PokemonApi::class.java)



    @Singleton
    @Provides
    fun providerPokemonRepository(api: PokemonApi): PokemonRepository {
        return PokemonRepositoryImpl(api)
    }
}